package com.qwz.learn;

/**
 * @Description: 线程安全，延迟初始化。这种方式采用双锁机制，安全且在多线程情况下能保持高性能。
 * @Author: Qiuwuzhi
 * @CreateDate: 2019/12/12  9:53
 * @Version V1.0
 */
public class SingletonDoubleSync {

    private SingletonDoubleSync() {
    }

    private static SingletonDoubleSync instance;

    public static SingletonDoubleSync getInstance() {
        if (instance == null) {
            synchronized (SingletonDoubleSync.class) {
                if (instance == null) {
                    instance = new SingletonDoubleSync();
                }
            }
        }
        return instance;
    }
}
